home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / enigma / earcd / emula / arosdv19.lha / AROS / exec / attemptsemaphoreshared.c < prev    next >
C/C++ Source or Header  |  1996-10-24  |  2KB  |  89 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: attemptsemaphoreshared.c,v 1.5 1996/10/24 15:50:45 aros Exp $
  4.     $Log: attemptsemaphoreshared.c,v $
  5.     Revision 1.5  1996/10/24 15:50:45  aros
  6.     Use the official AROS macros over the __AROS versions.
  7.  
  8.     Revision 1.4  1996/08/13 13:55:58  digulla
  9.     Replaced AROS_LA by AROS_LHA
  10.     Replaced some AROS_LH*I by AROS_LH*
  11.     Sorted and added includes
  12.  
  13.     Revision 1.3  1996/08/01 17:41:05  digulla
  14.     Added standard header for all files
  15.  
  16.     Desc:
  17.     Lang: english
  18. */
  19. #include "exec_intern.h"
  20. #include "semaphores.h"
  21.  
  22. /*****************************************************************************
  23.  
  24.     NAME */
  25.     #include <exec/semaphores.h>
  26.     #include <clib/exec_protos.h>
  27.  
  28.     AROS_LH1(ULONG, AttemptSemaphoreShared,
  29.  
  30. /*  SYNOPSIS */
  31.     AROS_LHA(struct SignalSemaphore *, sigSem, A0),
  32.  
  33. /*  LOCATION */
  34.     struct ExecBase *, SysBase, 120, Exec)
  35.  
  36. /*  FUNCTION
  37.     Tries to get a shared lock on a signal semaphore. If the lock cannot
  38.     be obtained false is returned. There may be more than one shared lock
  39.     at a time but an exclusive lock prevents all other locks. The lock
  40.     must be released with ReleaseSemaphore().
  41.  
  42.     INPUTS
  43.     sigSem - pointer to semaphore structure
  44.  
  45.     RESULT
  46.     True if the semaphore could be obtained, false otherwise.
  47.  
  48.     NOTES
  49.  
  50.     EXAMPLE
  51.  
  52.     BUGS
  53.  
  54.     SEE ALSO
  55.     ReleaseSemaphore()
  56.  
  57.     INTERNALS
  58.  
  59.     HISTORY
  60.     29-10-95    digulla automatically created from
  61.                 exec_lib.fd and clib/exec_protos.h
  62.  
  63. *****************************************************************************/
  64. {
  65.     AROS_LIBFUNC_INIT
  66.     AROS_LIBBASE_EXT_DECL(struct ExecBase *,SysBase)
  67.     LONG ret=0;
  68.  
  69.     /* Arbitrate for the semaphore structure */
  70.     Forbid();
  71.  
  72.     /*
  73.     If the semaphore is free, shared locked or owned by the current task
  74.     it's possible to get another lock.
  75.     */
  76.     if(sigSem->ss_NestCount<=0||sigSem->ss_Owner==SysBase->ThisTask)
  77.     {
  78.     /* Get it and return success */
  79.     ObtainSemaphoreShared(sigSem);
  80.     ret=1;
  81.     }
  82.  
  83.     /* All done. */
  84.     Permit();
  85.     return ret;
  86.     AROS_LIBFUNC_EXIT
  87. } /* AttemptSemaphoreShared */
  88.  
  89.